@extends('layouts.tankuang')

@section('content')
        <form name="add_form" id="add_form" action="{{url('admin/xz/xzedit',$id)}}" method="post" enctype="multipart/form-data">
            <input type="hidden" name="_token" value="{{ csrf_token() }}">
            <div id="div_print">
                <h2 class="text-center mg_b36 mg_t25" style="font-weight: bold;">金融机构行政许可备案</h2>
                <table class="table-form table-border w mg-auto">
                    <tbody>

                    

                    <tr>
                        <td class="font-bd" width="174">项目名称</td>
                        <td colspan="5"><input type="text" class="form-input w easyui-validatebox" value="{{$re->name}}" name="name" data-options="required:true,missingMessage:'项目名称不能为空',validateOnCreate:false,validateOnBlur:true"></td>
                    </tr>

                     <tr>
                        <td class="font-bd">申请单位</td>
                        <td>
                            <select id="company" name="unit_id" class="w150 input_all easyui-validatebox" style="width: 174px;" data-options="required:true,missingMessage:'申请单位不能为空',validateOnCreate:false,validateOnBlur:true">
                                <option value="">请选择</option>
                                @foreach($company as $v)
                                    <option value="{{$v->id}}" @if($unit->id==$v->id) selected @endif>{{$v->name}}</option>
                                @endforeach
                            </select>
                        </td>
                        <td class="font-bd" width="116">上级主管单位</td>
                        <td colspan="3">
                            <input type="text" class="form-input w easyui-validatebox"  name="up_unit" value="{{$re->up_unit}}" data-options="required:true,missingMessage:'上级主管单位不能为空',validateOnCreate:false,validateOnBlur:true">
                        </td>
                    </tr>

                    <tr>
                        <td class="font-bd">市、区、派出所</td>
                        <td colspan="5">
                            <div class="col-sm-3" style="margin-left: -15px;">
                                <select id="city" name="city" class="w150 input_all" style="width: 174px;" disabled>
                                    @if($ci)
                                     <option value="">{{$ci->name}}</option>
                                    @endif
                                </select>
                            </div>
                            <div class="col-sm-3" style="margin-left: 15px;">
                                <select id="area" name="area" class="w150 input_all" style="width: 174px;" disabled>
                                  <!--   <option value="">请选择</option> -->

                                   @if($ar)
                                     <option value="">{{$ar->name}}</option>
                                    @endif


                                </select>
                            </div>
                            <div class="col-sm-3" style="margin-left: 15px;">
                                <select id="org_id" name="org_id" class="w150 input_all" style="width: 174px;" disabled>
                                  <!--   <option value="">请选择</option> -->


                                   @if($or)
                                     <option value="">{{$or->name}}</option>
                                    @endif


                                </select>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="font-bd">详细地址</td>
                        <td colspan="5"><input type="text" class="form-input w"   name="address" id="address" value="{{$unit->address}}"disabled></td>
                    </tr>
                    <tr>
                        <td class="font-bd">法人代表(主要负责人)</td>
                        <td>
                            <input type="text" class="form-input"  name="fzr" id="fzr" value="{{$unit->frdb_name}}" disabled style="width: 174px;">
                        </td>
                        <td class="font-bd">联系电话</td>
                        <td colspan="3">
                            <input type="text" class="form-input" name="lxdh" id="lxdh" value="{{$unit->frdb_phone}}" disabled style="width: 174px;">
                        </td>
                    </tr>
                     <tr>
                        <td class="font-bd">工程类别</td>
                        <td colspan="5"><input name="gclb" type="radio" value="1" @if($re->gclb==1) checked @endif />营业场所 &nbsp; <input name="gclb" type="radio" value="2" @if($re->gclb==2) checked @endif/>金库 &nbsp; <input name="gclb" type="radio" value="3" @if($re->gclb==3) checked @endif/>自助银行 &nbsp; <input name="gclb" type="radio" value="4" @if($re->gclb==4) checked @endif/>自助机具</td>
                    </tr

                      <tr>
                        <td class="font-bd">工程属性</td>
                        <td colspan="5"><input name="gcsx" type="radio" value="1"  @if($re->gcsx==1) checked @endif/>新建 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input name="gcsx" type="radio" value="2" @if($re->gcsx==2) checked @endif/>改建</td>
                    </tr>
                     <tr>
                        <td class="font-bd">风险等级</td>
                        <td>
                            <input type="text" class="form-input"  name="fxdj" value="{{$re->fxdj}}" style="width: 174px;"/>
                        </td>
                        <td class="font-bd">防护级别</td>
                        <td colspan="2">
                            <input type="text" class="form-input"  name="fhjb" value="{{$re->fhjb}}" style="width: 174px;"/>
                        </td>
                    </tr>

                     <tr>
                        <td class="font-bd">报建时间</td>
                        <td>
                            <input type="text" name="bjsj"  class="easyui-datetimebox easyui-validatebox" style="width: 174px;" value="{{$re->bjsj}}" data-options="required:true,missingMessage:'报建时间不能为空',validateOnCreate:false,validateOnBlur:true"/>
                        </td>
                        <td class="font-bd">审批时间</td>
                        <td colspan="2">
                            
                            <input type="text" name="spsj"  class="easyui-datetimebox easyui-validatebox" style="width: 174px;" value="{{$re->spsj}}" data-options="required:true,missingMessage:'审批时间不能为空',validateOnCreate:false,validateOnBlur:true"/>
                        </td>
                    </tr>

                     <tr>
                        <td class="font-bd">验收时间</td>
                        <td>
                     
                            <input type="text" name="yssj"  class="easyui-datetimebox easyui-validatebox" style="width: 174px;" value="{{$re->yssj}}" data-options="required:true,missingMessage:'验收时间不能为空',validateOnCreate:false,validateOnBlur:true" />
                        </td>
                        <td class="font-bd">达标情况</td>
                        <td colspan="2">
                           <input name="is_ok" type="radio" value="1"  @if($re->is_ok==1) checked @endif />合格 &nbsp; <input name="is_ok" type="radio" value="2" @if($re->is_ok==2) checked @endif />不合格 &nbsp; 
                        </td>
                    </tr>

                    </tbody>
                </table>

            
                <div class="w wbt mg_t25 pd_b20 text-center">
                    <button id="go" type="button" class="easyui-linkbutton dsp" data-options="iconCls:'icon-save'">修改</button>
                    <a href="/admin/xz/view/{{$id}}" target="_blank" id="goToPageB" class="easyui-linkbutton dsp print" data-options="iconCls:'icon-print'">跳转至打印</a>
                    <button type="button" class="easyui-linkbutton dsp" data-options="iconCls:'icon-no'" onclick="$('#w').window('close')">关闭</button>
                </div>
            </div>
        </form>

        <script type="text/javascript">
            $(document).on("change",'#city', function(){

                $('#area option:gt(0)').remove();
                $('#org_id option:gt(0)').remove();
                //alert(1);die;
                var cid = $("#city").val();
                var url = "{{url('admin/getArea')}}";
                $.getJSON(url,{cid:cid},function(json){
                    /*清空原有的选项*/
                    if(json != ''){
                        $.each(json,function(index,array){
                            var option = "<option value='"+array['id']+"'";
                            option += ">"+array['name']+"</option>";
                            $("#area").append(option);
                        });
                    }
                });
            });

            $(document).on("change",'#area', function(){
                $('#org_id option:gt(0)').remove();
                var cid = $("#area").val();
                var url = "{{url('admin/getArea')}}";
                $.getJSON(url,{cid:cid},function(json){
                    /*清空原有的选项*/
                    if(json != ''){
                        $.each(json,function(index,array){
                            var option = "<option value='"+array['id']+"'";
                            option += ">"+array['name']+"</option>";
                            $("#org_id").append(option);
                        });
                    }
                });
            });
        </script>
        <script>


            $('#go').click(function (){
                if(!$("#add_form").form('validate')){
				return false;
				}
                $.ajax({
                    cache: true,
                    type: "POST",
                    url: "{{url('admin/xz/xzedit',$id)}}",
                    data: $('#add_form').serialize(),
                    async: false,
                    success: function(data) {
                        if(data.status == 1){

                            console.log(data);
                            $.messager.alert('信息提示',data.msg,'info');
                            $('#w').dialog('close');
                            $('.pagination-load').click();
                        }else {
                            $.messager.alert('信息提示',data.msg,'info');
                        }
                    },
                    error: function(msg) {
                        var json=JSON.parse(msg.responseText);
                        $.each(json, function(index, value) {
                            $.messager.alert('信息提示',value,'info');die;
                        });
                    },
                });
            });
        </script>

        <script type="text/javascript">
             $(document).on("change",'#company', function(){
                var url = "{{url('admin/xz/findcompany')}}"
                var id = $("#company").val();
                
                if (id == '') {
                     $('#city option').remove();
                     $('#area option').remove();
                     $('#org_id option').remove();
                     document.getElementById("address").value = '';
                     document.getElementById('fzr').value = '';
                     document.getElementById('lxdh').value = '';

                }



                $.getJSON(url,{id:id},function(json){
                     console.log(json);
                    if (json != '') {
                        //获取详细地址
                        console.log(json['company']['address']);
                        var address = json['company']['address'];
                        document.getElementById("address").value = address;

                        //获取法人
                        var fzr = json['company']['frdb_name'];
                        document.getElementById("fzr").value = fzr;

                        //获取联系方式
                        var lxdh = json['company']['frdb_phone'];
                        document.getElementById('lxdh').value = lxdh;

                        //获取城市
                         $('#city option').remove();
                         $('#area option').remove();
                         $('#org_id option').remove();
                         
                        var option = "<option>"+json['city']['name']+"</option>";
                        $("#city").append(option);

                         var option = "<option>"+json['area']['name']+"</option>";
                        $("#area").append(option);


                         var option = "<option>"+json['org']['name']+"</option>";
                        $("#org_id").append(option);
                       
                    }
                });

            });


        </script>



@stop